class WorkflowController:
    def __init__(self, generator, discriminator, max_iterations):
        """
        初始化流程控制模块
        :param generator: 提示词生成模块
        :param discriminator: 提示词评估模块
        :param max_iterations: 最大迭代次数
        """
        self.generator = generator
        self.discriminator = discriminator
        self.max_iterations = max_iterations

    def run(self, user_input):
        """
        执行提示词优化流程
        :param user_input: 用户需求描述
        :return: 最终优化的提示词
        """
        prompt = self.generator.generate(user_input)
        for _ in range(self.max_iterations):
            # 模拟测试结果
            test_result = f"生成的代码：print('Hello, World!')"
            feedback = self.discriminator.evaluate(prompt, test_result, user_input)
            if feedback == "无需改进":
                break
            prompt = feedback
        return prompt